<template>

  <div class="search">
		<input class="blur search_input" type="text" v-if="blurFlag" @focus="shiftFocus" placeholder="搜索" />
		<div v-if="focusFlag" class="focusInput">
			<input class="focus search_input" v-model="searchData" type="text" @input="SearchClick" @focus="clear" v-focus />
			<a @click="SearchClick">搜索</a>
			<a @click.prevent="shiftBlur">取消</a>
		</div>
		<span class="mui-icon mui-icon-search" :class="{'blurIcon':blurFlag,'focusIcon':focusFlag}"></span>
	</div>
</template>


<script>
	export default {
		data() {
			return {
				searchData:'',
				blurFlag: true,
				focusFlag: false,
			}
		},
		props:["searchMsg","src"],
		methods: {
			 shiftBlur() {
      this.blurFlag = true;
      this.focusFlag = false;
    },
    shiftFocus() {
      this.blurFlag = false;
      this.focusFlag = true;
    },
			clear(){
				this.searchData = ''
			},
			SearchClick(){
				this.$emit('fun',this.searchData)
			},
			shiftBlur() {
				this.blurFlag = true
				this.focusFlag = false
				this.$emit('fun')
			},
			shiftFocus() {
				this.blurFlag = false
				this.focusFlag = true

			}
		
      
    },
   
  }

</script>

<style scoped="scoped">
.focusInput a {
  margin-top: 4px;
  font-size: 15px;
  color: dodgerblue;
}

.blur {
  text-align: center;
}

.focusInput .focus {
  text-align: left;
  width: 74%;
  display: inline-block;
  padding-left: 20px;
}

.focusIcon {
  margin-left: 3px;
  margin-top: -22px;
}


.blurIcon {
  justify-content: center;
}

.search .mui-icon {
		display: flex;
		margin-top: -23px;
		font-size: 15px;
		color: #999999;
		margin-right: 70px;
	}




.search_input {
  background: white;
  height: 30px;
  border: none;
  outline: none;
  margin-bottom: 0;
  font-size: 16px;
	background: #EEEEEE;
	padding-top: 0;
	padding-bottom: 0;
}

.search {
  padding: 7px 5px 16px 5px;
	border-top: 1px solid #DDDDDD;
	border-bottom: 1px solid #DDDDDD;
}

input[type="color"],
input[type="date"],
input[type="datetime-local"],
input[type="datetime"],
input[type="email"],
input[type="month"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="text"],
input[type="time"],
input[type="url"],
input[type="week"],
select,
textarea {
  margin-bottom: 0;
}

input::-webkit-input-placeholder {
  /*WebKit browsers*/
  color: #999;
  font-size: 15px;
}

input::-moz-input-placeholder {
  /*Mozilla Firefox*/
  color: #999;
  font-size: 15px;
}

input::-ms-input-placeholder {
  /*Internet Explorer*/
  color: #999;
  font-size: 15px;
}
</style>
